<?php
/**
 * Datasource
 * 
 * @category	DataSource
 * @package		dayscript.datasource
 * @subpackage	
 * @author		Nelson Daza <ndaza@dayscript.com>
 * @copyright	2009 Dayscript Ltda.
 * @license		
 * @version		1.0
 * @version		$Revision: 0 $
 * @filesource	
 * @link		http://www.dayscript.com
 * @link		{docsLink}
 * @uses		
 * @since		1.0
 * @modifiedby	$LastChangedBy: Nelson Daza $
 * @modified	$Date: 2009-08-13 $
 */

namespace dayscript\datasource;

/**
 * Datasource
 * 
 * Interface
 * 
 * @category	DataSource
 * @package		dayscript.datasource
 * @subpackage	
 * @author		Nelson Daza <ndaza@dayscript.com>
 * @copyright	2009 Dayscript Ltda.
 * @license		
 * @version		1.0
 * @link		http://www.dayscript.com
 * @link		{docsLink}
 * @uses		\dayscript\cache\Cacheable, \dayscript\Map, \dayscript\log\LogManager
 * @since		1.0
 * @modifiedby	$LastChangedBy: Nelson Daza $
 * @modified	$Date: 2009-08-28 $
 */
interface DataSource extends \dayscript\cache\Cacheable	{
	/**
	 * Returns a unique identifier for this Datasource
	 * @return string $name
	 */
	public function getName( );
	/**
	 * Initializes the object parameters.
	 * @param string $name Connection name
	 * @param \dayscript\Map $conf Connection configuration Config
	 */
	public function init( $name, \dayscript\Map $conf = null );
	/**
	 * Open Datasource Connection
	 * @throws \Exception
	 * TODO this have to know who created
	 */
	public function openConnection( );
	/**
	 * Returns whether this Datasource is connected to its source
	 * @return boolean $isConnected
	 */
	public function isConnected( );
	/**
	 * Close Datasource Connection
	 * @return boolean $isClosed
	 */
	public function closeConnection( );
	/**
	 * Returns the Datasource Connection Object or Resource
	 * @return object|resource|null $connection
	 */
	public function getConnection( );
	/**
	 * Returns the Datasource Configuration Array
	 * @return array $config
	 */
	public function getConfig( );
	/**
	 * Executes the cleanup and shutdown procedure.
	 */
	public function destroy( );
	/**
	 * Whether datasource can Log actions.
	 */
	public function canLog( );
	/**
	 * Log for datasource actions.
	 */
	public function log( $message, $logType = \dayscript\log\LogManager::LOG_DATASOURCE );
}